package com.tiaoshi.thenwhat.common.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.tiaoshi.thenwhat.common.dao.PersonRepository;
import com.tiaoshi.thenwhat.common.entity.common.Person;

@Component("myService")
public class MyService {
	@Autowired
	private PersonRepository repository;

	public void doWork() {
		Person person = new Person();
		person.setFirstname("Oliver");
		person.setLastname("Gierke");
		repository.insert(person);
		
		System.out.println(repository.findAll().get(1).toString());
	}
	
	public List<Person> getList(){
		return repository.findAll();
	}
	
	public Object getById(String id){
		return repository.findById(id, Person.class);
	}
}
